package org.lift.gui;

import java.awt.Color;
import java.util.List;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import org.lift.Lift;



@SuppressWarnings("unused")
public class Lift1 {

	public static void main(String[] args) {
		JFrame frame = new JFrame();
		JPanel panel1 = new JPanel();
		frame.add(panel1);
		int stockanzahl = 10;
		int unterstesStockwerk = -3;
		final Lift unserLift = new Lift();
		unserLift.kalibrieren();
		final ArrayList<JButton> buttonList = new ArrayList<JButton>();
		
		for(int i = unterstesStockwerk + stockanzahl -1; i >= unterstesStockwerk; i--) {
			
			final JButton button = new JButton();
			final int stockwerk = i;
			String buttonText = "Stock " + stockwerk;
			
			button.setText(buttonText);
			panel1.add(button);
			
			ActionListener listener = new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					resetButtoncolor();
					unserLift.zielEingeben(stockwerk);
					button.setBackground(new Color(255,255,204));
					}
				
				
				private void resetButtoncolor() {
					for (JButton jbutton : buttonList) {
						jbutton.setBackground(null);
					}
				}
			};
			
			button.addActionListener(listener);
			buttonList.add(button);
				
		}
		
		frame.setSize(400,400);
		frame.setVisible(true);
		
		
		panel1.setSize(400,400);
		panel1.setVisible(true);
		
		
	}
	
}